package com.tyd.cams.Adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.tyd.cams.zixunfragment.JiaoWuFragment;
import com.tyd.cams.zixunfragment.SchoolGongFragment;
import com.tyd.cams.zixunfragment.SchoolZiXunFragment;

import java.util.ArrayList;

/**
 * @author: TYD
 * @作者: 唐YaDong
 * @date: 2021/3/14 21:07
 * @description：ZiXunAdapter
 * @描述：ZiXunAdapter
 * @版本：1.0
 */
public class ZiXunViewPagerAdapter extends FragmentPagerAdapter {
    ArrayList<Fragment> fragments = new ArrayList<>();
    ArrayList<String> strings = new ArrayList<>();

    public ZiXunViewPagerAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

//    public ZiXunViewPagerAdapter(@NonNull FragmentManager fm, int behavior) {
//        super(fm, behavior);
//    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return new JiaoWuFragment();
            case 1:
                return new SchoolGongFragment();
            case 2:
                return new SchoolZiXunFragment();
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    public void add(Fragment fg, String str) {
        fragments.add(fg);
        strings.add(str);
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return strings.get(position);
    }
}
